package icu.qx.diagram.controller;


import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.security.utils.SecurityUtils;
import icu.qx.diagram.domain.MaterialOutbound;
import icu.qx.diagram.domain.Outbound;
import icu.qx.diagram.service.IOutboundService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List;

import static com.ruoyi.common.core.utils.PageUtils.startPage;

@RestController
@RequestMapping("/diagram/outbound")
public class OutboundController extends BaseController{
    private final IOutboundService outboundService;
    @Autowired
    public OutboundController(IOutboundService outboundService){this.outboundService=outboundService;}

    /**
     * 查询产量统计
     */
    @RequiresPermissions("diagram:outbound:list")
    @GetMapping("/list")
    public TableDataInfo list(Outbound outbound)
    {
        startPage();
        List<Outbound> list=outboundService.selectOutboundList(outbound);
        for(Outbound o:list){
            o.setCreatorName(SecurityUtils.getUsername());
        }
        return  getDataTable(list);
    }
    /**
     * 导出产量统计
     */
    @RequiresPermissions("diagram:outbound:export")
    @Log(title = "产量统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Outbound outbound) {
        List<Outbound> list = outboundService.selectOutboundList(outbound);
        ExcelUtil<Outbound> util = new ExcelUtil<>(Outbound.class);
        util.exportExcel(response, list, "产量统计数据");
    }
}
